package com.lv.phuotbacnam.ui.adapter;

import java.util.List;

import android.support.v4.view.PagerAdapter;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.lv.phuotbacnam.R;

public class ResourcePicsAdapter extends PagerAdapter {

    private List<Integer> imageResources;

    public ResourcePicsAdapter(List<Integer> imageResources) {
        this.imageResources = imageResources;
    }

    @Override
    public Object instantiateItem(ViewGroup container, int position) {

        View partyItem= LayoutInflater.from(container.getContext())
                .inflate(R.layout.fragment_start_viewpager_img, container, false);
        ImageView partyPic = (ImageView)partyItem.findViewById(R.id.start_phuot_pic);
        partyPic.setImageResource(imageResources.get(position));

        container.addView(partyItem, 0);

        return partyItem;
    }

    @Override
    public void destroyItem(ViewGroup container, int position, Object object) {
        container.removeView((View) object);
    }

    @Override
    public int getCount() {
        return imageResources.size();
    }

    @Override
    public boolean isViewFromObject(View view, Object object) {
        return view == object;
    }
}
